#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netinet/in.h>

int main(void)
{
   int sockfd = -1;
   struct ifreq ifr;

   sockfd = socket(AF_INET, SOCK_DGRAM, 0);
    if( sockfd < 0 )
    {
	    printf("sockfd\n");
	    return -1;
    }

   strncpy(ifr.ifr_name, "wlan0", 6);
   if( ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0  )
   {
	   printf("ioctl error\n");
	   return -1;
   }

   printf("flags:%d\n", ifr.ifr_flags);
   //ifr.ifr_flags &= ~IFF_UP;
   ifr.ifr_flags |= IFF_UP;
   if( ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0  )
   {
	   printf("ioctl error\n");
	   return -1;
   }

}
